package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.dto.NursingPlanProjectDto;
import com.zzyl.entity.NursingPlanProject;
import com.zzyl.mapper.NursingPlanProjectMapper;
import com.zzyl.service.NursingPlanProjectService;
import com.zzyl.vo.NursingPlanProjectVo;
import com.zzyl.vo.NursingPlanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NursingPlanProjectServiceImpl implements NursingPlanProjectService {
    @Autowired
    private NursingPlanProjectMapper nursingPlanProjectMapper;
    @Override
    public void saveBatch(List<NursingPlanProjectDto> list, Long planId) {
        for (NursingPlanProjectDto nursingPlanProjectDto : list) {
            nursingPlanProjectDto.setPlanId(planId);
        }
        List<NursingPlanProject> nursingPlanProjects = BeanUtil.copyToList(list, NursingPlanProject.class);
        nursingPlanProjectMapper.insertBatch(nursingPlanProjects);
    }

    @Override
    public List<NursingPlanProjectVo> findByPlanId(Long planId) {
        List<NursingPlanProjectVo> list = nursingPlanProjectMapper.selectByPlanId(planId);
        return list;
    }

    @Override
    public void delete(Long planId) {
        nursingPlanProjectMapper.delete(planId);
    }
}
